package regexplus;

public class SegmentedString implements CharSequence {

	public String text = null;
	public String[] token = null;
	public String[] pos = null;
	public int[] c2tindex = null;
	
	public SegmentedString(String text, String[] tok, String[] pos) {
		if(text==null || tok==null || pos==null || tok.length!=pos.length)
			return;
		this.text = text;
		this.token = tok;
		this.pos = pos;
		c2tindex = new int[this.text.length()];
		int tokstart = 0;
		for(int i=0; i<c2tindex.length; i++) {
			c2tindex[i] = -1;
		}
		for(int i=0; i<tok.length; i++) {
			c2tindex[tokstart] = i;
			tokstart = tokstart + this.token[i].length();
		}
	}
	
	public char charAt(int arg0) {
		return text.charAt(arg0);
	}

	public int length() {
		return text.length();
	}

	public CharSequence subSequence(int arg0, int arg1) {
		return text.subSequence(arg0, arg1);
	}
}
